var net = require("net");

console.log('type "exit" or "quit" to quit.');

// sock is an instance of net.Socket
var sock = net.connect({port: 18036}, function(){
    console.log('server connected');
    sock.setEncoding('utf8');

    var loginCommand = {
        "command": "login",
        "version":"0.1",
        "id":"b5265010-bb7a-11e6-a60f-77d95c87b193",
        "data":{
            "userName":"zzgghh",
            "password":"33333333",//如果支持其他登录方式，这里的信息可能是其他的
            "loginType":"dependency",//dependency|singleton  用户单独登录，或者依赖客户端登录
            "clientNature":"enzyme"//可选参数，用户在依赖模式登录下必填
        }
    }
    var loginStr = JSON.stringify(loginCommand);
    console.log(loginStr.length);
    /*sleep(5000);*/
    sock.write("-S-00000179"+loginStr);
});

sock.on('data', function(data){
    console.log('got data from server - ', data);
});

sock.on('end', function(){
    console.log('client disconnected');
});

sock.on('error', function(err){
    console.log('socket error - ', err);
});

sock.on('close', function(){
    console.log('echo client was closed');
});